package com.googlecode.esblabs.cmf.util;


import com.googlecode.esblabs.cmf.AcknowledgeSalesOrderDataAreaType;
import com.googlecode.esblabs.cmf.AcknowledgeSalesOrderType;
import com.googlecode.esblabs.cmf.ApplicationAreaType;
import com.googlecode.esblabs.cmf.CustomerPartyType;
import com.googlecode.esblabs.cmf.ProcessSalesOrderDataAreaType;
import com.googlecode.esblabs.cmf.ProcessSalesOrderType;
import com.googlecode.esblabs.cmf.SalesOrderHeaderType;
import com.googlecode.esblabs.cmf.SalesOrderType;
import com.googlecode.esblabs.util.Util;

public class TestUtil {

	static public final String EXPECTED_CUSTOMER_NAME = "Magnus Larsson";

	static public AcknowledgeSalesOrderType createAcknowledgeSalesOrder() {
		AcknowledgeSalesOrderType a = new AcknowledgeSalesOrderType();

		a.setApplicationArea(getApplicationArea());
		
		AcknowledgeSalesOrderDataAreaType da = new AcknowledgeSalesOrderDataAreaType();
		a.setDataArea(da);

		SalesOrderType s = new SalesOrderType();
		da.getSalesOrder().add(s);
		
		SalesOrderHeaderType h = new SalesOrderHeaderType();
		s.setSalesOrderHeader(h);
		
		CustomerPartyType c = new CustomerPartyType();
		h.setCustomerParty(c);
		
		c.setName(EXPECTED_CUSTOMER_NAME);

		return a;
	}

	static public ProcessSalesOrderType createProcessSalesOrder() {
		ProcessSalesOrderType a = new ProcessSalesOrderType();
		
		a.setApplicationArea(getApplicationArea());

		ProcessSalesOrderDataAreaType da = new ProcessSalesOrderDataAreaType();
		a.setDataArea(da);
		
		SalesOrderType s = new SalesOrderType();
		da.getSalesOrder().add(s);
		
		SalesOrderHeaderType h = new SalesOrderHeaderType();
		s.setSalesOrderHeader(h);
		
		CustomerPartyType c = new CustomerPartyType();
		h.setCustomerParty(c);
		
		c.setName(EXPECTED_CUSTOMER_NAME);

		return a;
	}
	
	private static ApplicationAreaType getApplicationArea() {
		ApplicationAreaType a = new ApplicationAreaType();
		a.setSender("TestSender");
        a.setCreationDateTime(Util.getCurrentDateTime());
        a.setBODID(Util.getBodId());
        return a;
	}

}